#pragma once

#include "Config.h"
#include "Container.h"
#include "DBRecord.h"
#include "DBStream.h"
#include "DBFileStream.h"

#ifdef _DB_USE_ZLIB
#include "DBCompressedStream.h"
#endif

#include "DBStringContainer.h"
#include "DBSimpleContainer.h"
#include "DBDataContainer.h"

namespace db
{

static const u16 DB_VERSION = 
    (0 << 0) +    // MINOR
    (1 << 8);     // MAJOR
static const char DB_HEADER[] = {'.', 'D', 'T', 'B', 'S'};

typedef enum {
    RF_HAS_NAME          = (1 << 0),
    RF_HAS_DATA          = (1 << 1),
    RF_HAS_CHILD         = (1 << 2),
    RF_ARRAY             = (1 << 3)
} ERecordFlags;

class DataBase : public Record
{
public:

    bool Load(ReadStream& file); 
    bool Save(WriteStream& file); 

    void Clear();
    
    bool LoadFromFile(const std::string& fileName, bool decompress = true);
    bool SaveToFile(const std::string& fileName, bool compress = true);

	DataBase();
};

};